<%@ WebService Language="VB" Class="UpdateScore" %>

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient

<WebService(Namespace:="http://wroxunited.net/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class UpdateScore
    Inherits System.Web.Services.WebService
    
    Public Sub Goal(ByVal FixtureID As Integer, ByVal PlayerID As Integer, ByVal GoalTime As Integer)

        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("WroxUnited").ConnectionString)
        conn.Open()
        Dim cmd As New SqlCommand("usp_Goal", conn)
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.Add("@FixtureID", SqlDbType.Int).Value = FixtureID
        cmd.Parameters.Add("@PlayerID", SqlDbType.Int).Value = PlayerID
        cmd.Parameters.Add("@GoalTime", SqlDbType.Int).Value = GoalTime

        cmd.ExecuteNonQuery()

    End Sub

    <WebMethod()> _
    Public Sub UpdateGoals(ByVal FixtureID As Integer, ByVal GoalFor As Boolean, ByVal PlayerID As Integer, ByVal GoalTime As Integer)


        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("WroxUnited").ConnectionString)
        conn.Open()
        Dim cmd As New SqlCommand("usp_UpdateScore", conn)
        
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.Add("@FixtureID", SqlDbType.Int).Value = FixtureID
        cmd.Parameters.Add("@GoalFor", SqlDbType.Bit).Value = GoalFor

        cmd.ExecuteNonQuery()

        If GoalFor Then
            Goal(FixtureID, PlayerID, GoalTime)
        End If
    End Sub

End Class
